<%@page import="ext.acae2.baseline.resource.BaselineActionResource"%>
<%@page import="wt.util.WTMessage"%>
<%@page import="ext.acae2.baseline.web.DownloadCompareBaseline"%>
<%@page import="wt.fc.ReferenceFactory"%>
<%@page import="wt.vc.baseline.ManagedBaseline"%>
<%@page import="java.io.OutputStream"%>
<%@page contentType="text/html;charset=UTF-8"%>
<%
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");

String baselineAOid = request.getParameter("baselineAOid");
String baselineBOid = request.getParameter("baselineBOid");

if (baselineAOid == null || baselineBOid == null) {
    out.println("<script>window.close();</script>");
    return;
}

ManagedBaseline baselineA = (ManagedBaseline) new ReferenceFactory().getReference(baselineAOid).getObject();
ManagedBaseline baselineB = (ManagedBaseline) new ReferenceFactory().getReference(baselineBOid).getObject();

response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment; filename=" 
//+ WTMessage.getLocalizedMessage(BaselineActionResource.class.getName(), BaselineActionResource.BASELINE_COMPARE_REPORT)
+ baselineA.getNumber() + "_" + baselineB.getNumber() + ".xls" );

out.clear();
out = pageContext.pushBody();
OutputStream outputStream = response.getOutputStream();

DownloadCompareBaseline.download(baselineA, baselineB, outputStream);

out = pageContext.pushBody();
out.println("<script>window.close();</script>");
%>